import java.util.LinkedList;
import java.util.Queue;

/**
 * Created by L.jp
 * Description:
 * User: 86189
 * Date: 2021-10-10
 * Time: 13:57
 */
class TreeNode {
     int val;
     TreeNode left;
     TreeNode right;
     TreeNode() {}
     TreeNode(int val) { this.val = val; }
     TreeNode(int val, TreeNode left, TreeNode right) {
         this.val = val;
         this.left = left;
         this.right = right;
     }
  }
public class BinaryTree {
    public boolean isCompleteTree(TreeNode root) {
        if(root==null){
            return true;
        }
        Queue<TreeNode> queue=new LinkedList<>();
        queue.offer(root);
        while(!queue.isEmpty()){
            TreeNode top=queue.poll();
            if(top==null){
                break;
            }
            queue.offer(top.left);
            queue.offer(top.right);
        }
        while(!queue.isEmpty()){
            TreeNode top=queue.peek();
            if(top!=null){
                return false;
            }
            queue.poll();
        }
        return true;
    }

}
